package com.enqualcomm.kids.activities;


import android.widget.ImageView;
import android.widget.TextView;

import com.enqualcomm.kids.R;
import com.enqualcomm.kids.base.BaseActivity;
import com.enqualcomm.kids.bean.Constellation;
import com.enqualcomm.kids.config.userdefault.UserTerminalDefault;
import com.enqualcomm.kids.mvp.reai.ConstellationUtil;
import com.enqualcomm.kids.network.socket.response.QueryUserTerminalInfoResult;
import com.enqualcomm.kids.network.socket.response.TerminallistResult;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;
import org.androidannotations.annotations.ViewById;

@EActivity(R.layout.activity_constellation)
public class ConstellationActivity extends BaseActivity {

    @Extra("terminal")
    TerminallistResult.Terminal terminal;
    private Constellation constellation;

    @ViewById(R.id.constellation_iv)
    ImageView constellation_iv;
    @ViewById(R.id.constellation_tv)
    TextView constellation_tv;
    @ViewById(R.id.duration_tv)
    TextView duration_tv;
    @ViewById(R.id.bg_iv)
    ImageView bg_iv;
    @ViewById(R.id.desc_tv)
    TextView desc_tv;
    @ViewById(R.id.luck_num_tv)
    TextView luck_num_tv;
    @ViewById(R.id.luck_flower_tv)
    TextView luck_flower_tv;
    @ViewById(R.id.constellation_token_iv)
    ImageView constellation_token_iv;

    @AfterViews
    void setupViews(){
        QueryUserTerminalInfoResult.Data info = new UserTerminalDefault(terminal.userterminalid).getInfo();
        setupTitleIcon(info, terminal.terminalid, terminal.userterminalid, getString(R.string.star_title));
        constellation = ConstellationUtil.birthdayToConstellation(this,info.birthday);
        bindData();
    }

    private void bindData() {
        constellation_iv.setImageResource(constellation.bigImageId);
        constellation_tv.setText(constellation.name);
        duration_tv.setText(constellation.duration);
        bg_iv.setImageResource(constellation.backgroundId);
        desc_tv.setText(constellation.desc);
        luck_num_tv.setText(constellation.luckNum);
        luck_flower_tv.setText(constellation.luckFlower);
        constellation_token_iv.setImageResource(constellation.tokenImageId);
    }

    @Click(R.id.title_bar_left_iv)
    void goBack(){
        finish();
    }

}
